#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
char arr[30][60] = { 0 };
int m = 30, n = 60;
int ret = 0;
int counts = 0;
int dx[4] = { -1,1,0,0 };
int dy[4] = { 0,0,1,-1 };
void dfs(char arr[30][60],int i,int j)
{
	counts++;
	arr[i][j] = '0';
	for (int k = 0; k < 4; k++)
	{
		int x = i+dx[k] , y = j+dy[k];
		if (0 <= x && x < m && 0 <= y && y < n && arr[x][y]=='1')
		{
			dfs(arr, x, y);
		}
	}
}
int main()
{
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cin >> arr[i][j];
		}
	}
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (arr[i][j] == '1')
			{
				counts = 0;
				dfs(arr,i,j);
				ret = max(ret, counts);
			}
		}
	}
	cout << ret;
	return 0;
}